package cn.lg.soar.message.event;

import cn.lg.soar.message.api.enums.WebSocketEventTypeEnum;

import java.time.Clock;

/**
 * websocket打开事件
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public class WebSocketMessageEvent extends WebSocketEvent {

    private String topic;

    public WebSocketMessageEvent(String tokenId, String topic, String message) {
        super(WebSocketEventTypeEnum.message, tokenId, message);
        this.topic = topic;
    }

    public WebSocketMessageEvent(String tokenId, String topic, String message, Clock clock) {
        super(WebSocketEventTypeEnum.message, tokenId, message, clock);
        this.topic = topic;
    }

    public String getTopic() {
        return topic;
    }

    public String getMessage() {
        return (String) getSource();
    }

    @Override
    public String toString() {
        return "WebSocketMessageEvent{" +
                "clientId=" + clientId +
                ", topic=" + topic +
                ", message=" + source +
                '}';
    }
}
